

package simuri.uridb;

import com.mysql.jdbc.Connection;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

/**
 *
 * @author fomy
 */
public class DbConnection {
    
     
 public static Connection getConnection() { 
     
       Connection con = null;
        String dblocation = null;    
        String username = null;  
        String password = null;
     
       Properties props = new Properties();
       try{
          
        FileInputStream in = new FileInputStream("C:\\database-configuration.xml");
        props.loadFromXML(in);
        String driver = props.getProperty("driver");
        dblocation = props.getProperty("dblocation");    
        username = props.getProperty("username");  
        password = props.getProperty("password");
         con = (Connection) DriverManager.getConnection(dblocation, username, password);
       }catch(IOException | SQLException e){
        System.err.println("Error: " + e.getMessage());   
       }
            
       return con;
    } 
           
  }  

